package com.tencent.controller;

import com.tencent.Product;
import com.tencent.StoreService;
import com.tencent.dto.ProductDto;
import com.tencent.service.ProductService;
import com.tencent.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @PostMapping("/add")
    public Result add(@RequestBody ProductDto productDto){
//        try {
//            productService.add(productDto);
//            return new Result();
//        } catch (Exception e) {
//            e.printStackTrace();
//            return new Result(false, "产品添加失败");
//        }
        return productService.add(productDto);
    }
}
